![]() |
PATH![]() |
The USB standard specifies one of the fields of a control request as a BMRequestType . This field is a bit-mapped byte that tells the USB function about the request. Information about the request includes direction of data flow, how the function is defined (standard, class, or vendor specific) and what logically is the recipient of the request.
The USBMakeBMRequestType function formats device and control request type parameters into the bmRequestType format, which are passed to the USL in the usbBMRequestType field of the USBDeviceRequest function.
The USBMakeBMRequestType function returns a UInt8 or 0xff if one or more of the parameters is incorrect. A value of 0xff is not a legal value and is not accepted by the subsequent control call.
OSStatus USBMakeBMRequestType(UInt8 direction, UInt8 type,
UInt8 recipient);
All USB devices respond to requests from the host on the device's default pipe. These requests are made using control transfers. The request and the request's parameters are sent to the device in the setup packet.
The USBDeviceRequest function performs control transactions to default pipe 0 (zero) of a device.
OSStatus USBDeviceRequest(USBPB *pb);
Required fields in the USBPB parameter block for the USBDeviceRequest function are
The request is sent to the default pipe 0 and the relevant data is transferred.
The flag kUSBAddressRequest supports USB control transactions addressed to an interface or endpoint of a device. The kUSBAddressRequest flag allows the control call to be made without the driver explicitly knowing the number of the endpoint or interface before the call is made. The USL fills in the interface or endpoint number in the setup packet based on the pipe or interface reference that is passed in with the call.
To use the addressed device request feature, specifiy the kUSBAddessRequest flag in the usbFlags field. If the recipient field of the BMRequestType is an endpoint or interface, the relevant endpoint or interface number is derived from the pipe or interface reference that is passed in the usbReference field. The interface or endpoint number is put into the WIndex field of the setup packet before the control transaction call takes place.
For additional information about the parameters specified for control transactions, see section 9 of the USB Specification.
If the request is a set_config request, the USBDeviceRequest function returns the same errors as those for the USBOpenDevice function. Other errors returned by the USBDeviceRequest function include
Previous | Back Up One Level | Next |